package be.donovan.gui.helper;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JRViewer;

import org.springframework.core.io.DefaultResourceLoader;

public class JasperViewer {
	public static void main(String[] args) throws IOException, JRException {
		InputStream inputStream  = new DefaultResourceLoader().getResource("StyledTextReport.jasper").getInputStream();
		
		Map parameters = new HashMap();
		// Third, get a database connection
		// Fourth, create JasperPrint using fillReport() method
		JasperPrint jasperPrint = JasperFillManager.fillReport((JasperReport)JRLoader.loadObject(inputStream), 
		   parameters);
		//net.sf.jasperreports.view.JasperViewer.viewReport(inputStream,false,true);
		net.sf.jasperreports.view.JasperViewer.viewReport(jasperPrint);
	}

}
